﻿// Shader-Based-Image-Processing (SBIP)
// http://code.google.com/p/sbip/
//
// Copyright © Frank Nagl, 2009-2012
// admin@franknagl.de
//
namespace SBIP.OptionsForms
{
    using System;
    using System.Windows.Forms;
    using Filter;

    /// <summary>Filter specified properties form.</summary>
    public partial class LightingForm : Form
    {
        private readonly Lighting filter;

        /// <summary>
        /// Initializes a new instance of the <see cref="LightingForm"/> class.
        /// </summary>
        /// <param name="processor">The processor.</param>
        public LightingForm(Processor processor)
        {
            InitializeComponent();
            filter = new Lighting();
            processor.Filter = filter;
        }

        private void TrbarBlueValueChanged(object sender, EventArgs e)
        {
            filter.LightB = trbarBlue.Value;
            lbBlue.Text = trbarBlue.Value.ToString();

            if (rdbtnSyncYes.Checked)
            {
                trbarGreen.Value = trbarBlue.Value;
                trbarRed.Value  = trbarBlue.Value;
            }
        }

        private void TrbarGreenValueChanged(object sender, EventArgs e)
        {
            filter.LightG = trbarGreen.Value;
            lbGreen.Text = trbarGreen.Value.ToString();

            if (rdbtnSyncYes.Checked)
            {
                trbarBlue.Value = trbarGreen.Value;
                trbarRed.Value = trbarGreen.Value;
            }
        }

        private void TrbarRedValueChanged(object sender, EventArgs e)
        {
            filter.LightR = trbarRed.Value;
            lbRed.Text = trbarRed.Value.ToString();

            if (rdbtnSyncYes.Checked)
            {
                trbarBlue.Value = trbarRed.Value;
                trbarGreen.Value = trbarRed.Value;
            }
        }

        private void RdbtnSyncYesCheckedChanged(object sender, EventArgs e)
        {
            if (rdbtnSyncYes.Checked)
            {
                trbarBlue.Value = trbarRed.Value;
                trbarGreen.Value = trbarRed.Value;                
            }
        }
    }
}
